<ui:composition template="/WEB-INF/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <ui:define name="head">
        <title>Personal Data</title>
    </ui:define>
    <ui:define name="content">
        <h:form>
            <h:panelGrid id="userDataGrid" columns="3">
                <p:outputLabel value="Name" for="name" />
                <p:inputText id="name" value="#{userBean.currentUser.name}" >
                    <p:ajax update="nameMsg" />
                </p:inputText>
                <p:message id="nameMsg" for="name" />
                <p:outputLabel value="Surname" for="surname" />
                <p:inputText id="surname" value="#{userBean.currentUser.surname}" >
                    <p:ajax update="surnameMsg" />
                </p:inputText>
                <p:message id="surnameMsg" for="surname" />
                <p:outputLabel value="New Password" for="newPassword" />
                <p:password id="newPassword" value="#{userBean.currentUser.password}"
                            match="confirmPassword" feedback="true" />
                <p:message  for="newPassword" />
                <p:outputLabel value="Confirm New Password" for="confirmPassword" />
                <p:password id="confirmPassword" />
            </h:panelGrid>
            <h:panelGrid columns="2">
                <p:commandButton value="Save" action="#{userBean.save()}" update="userDataGrid" />
                
            </h:panelGrid>
        </h:form>
        <h:form>
            <p:commandButton value="Cancel Profile" action="#{userBean.cancelProfile()}" />
        </h:form>
    </ui:define>
</ui:composition>